<%@ include file="/includes/includes.jsp" %>
<%@ page language="Java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<div class="margin2ptb">
    <a href="/admin/addPermission.do" title="<spring:message code='add'/>"><img
            border="0" src="/images/add.gif" alt="<spring:message code='add'/>"></a>
</div>
<div class="table_wrapper">
    <div>
        <div>
            <div style="width: 100%;">
                <table border="0" cellspacing="0" cellpadding="0" class="table_data">
                    <thead>
                    <tr>
                        <th class="th_data_first"></th>
                        <th class="th_data"><spring:message code='code'/></th>
                        <th class="th_data"><spring:message code='name'/></th>
                        <th class="th_data"><spring:message code='description'/></th>
                        <th class="th_data"><spring:message code='roles'/></th>
                    </tr>
                    </thead>
                    <c:forEach var="permission" items="${appPermissionsList}" varStatus="permissionindex">
                        <tr class="${permissionindex.index % 2 == 0 ? 'even' : 'odd'}">
                            <td class="td_data_first">
                                <a href="/admin/viewPermission.do?permissionId=${permission.id}"
                                   title="<spring:message code='view'/>"><img border="0"
                                                                              src="/images/view.gif"
                                                                              alt="<spring:message code='view'/>"></a>
                                <a href="/admin/editPermission.do?permissionId=${permission.id}"
                                   title="<spring:message code='edit'/>"><img border="0"
                                                                              src="/images/edit.gif"
                                                                              alt="<spring:message code='edit'/>"></a>
                                <a href="/admin/deletePermission.do?permissionId=${permission.id}"
                                   title="<spring:message code='delete'/>"><img
                                        border="0" src="/images/delete.gif" alt="<spring:message code='delete'/>"></a>
                            </td>
                            <td class="td_data">${permission.code}</td>
                            <td class="td_data">${permission.name}</td>
                            <td class="td_data">${permission.description}</td>
                            <td class="td_data">
                                <c:choose>
                                    <c:when test="${not empty permission.roles}">
                                        <c:forEach var="role" items="${permission.roles}" varStatus="roleindex">
                                            <a href="/admin/viewRole.do?roleId=${role.id}"
                                               title="<spring:message code='view'/>">
                                                <c:out value="${role.name}"/>
                                            </a>
                                            <c:if test="${not roleindex.last}"><br></c:if>
                                        </c:forEach>
                                    </c:when>
                                    <c:otherwise><spring:message code="roles.not.defined"/></c:otherwise>
                                </c:choose>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
            </div>
        </div>
    </div>
    <%--<ui:include src="/resources/includes/pagination.xhtml">--%>
    <%--<ui:param name="paginationBean" value="${permissionsTable}"/>--%>
    <%--</ui:include>--%>
</div>